package com.jdlm;

import com.dm.service.DmService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

@Slf4j
@Service
public class JdlmService {

    @Autowired
    private DmService dm;
    private int hind = 0;

    @PostConstruct
    public void postCon(){
        log.info("启动京东联盟识别");
        bindJdlm();
    }

    public String startShibie(String url){
        log.info("开始转链，url:{}",url);
        return dm.jdlm(hind, url);
    }

    public static void main(String[] args) throws InterruptedException {
        JdlmService j = new JdlmService();
        j.dm = new DmService();
        j.bindJdlm();
        Thread.sleep(1000);
        String s = j.startShibie("https://u.jd.com/5iuXD5N");
        log.info("识别结果：{}",s);
    }

    private void bindJdlm() {
        int id = dm.findWindow("", "京东联盟");
        hind = id;
        log.info("获取到的id：{}", id);
    }
}
